# -*- coding: utf8 -*-
from ConfigParser import ConfigParser, NoOptionError

from nmj.updater import NMJUpdater


class Configuration(object):
	def __init__(self, config_file):
		self.config_file = config_file
		self.config=ConfigParser()
		self.config.read(config_file)

	def get_libraries(self):
		str_libraries = self.config.get("path", "libraries")
		return eval(str_libraries)

	def get_description(self, library_name):
		try:
			return self.config.get(library_name, "description")
		except NoOptionError:
			return ""

	def get_updater(self, name):
		return NMJUpdater(self.config.get(name, "rootpath"))

	def get_id(self, name):
		return self.config.get(name, "id")
